import { NetInfo } from 'react-native'

// let netJudgeTime = 0

function isNetLink () {
  return new Promise((resolve, reject) => {
    NetInfo.isConnected.fetch().then(isConnected => {
      console.log('isConnected', isConnected)
      if (isConnected) {
        resolve()
      } else {
        reject(new Error('无网络'))
      }
    })
  })
  // return
  //   console.log('netJudgeTime:', netJudgeTime)
  //   if (netJudgeTime < 3) {
  //     netJudgeTime++
  //     reject(new Error('无网络'))
  //   } else {
  //     resolve()
  //   }
  //
}

export { isNetLink }